'use strict';

module.exports = appInfo => {
  const config = exports = {};

  config.keys = appInfo.name + '_1592958404225_6133';
  //添加view配置
  config.view = {
    defaultViewEngine: '.ejs',
    mapping: {
      '.html': 'ejs'
    }
  }
  // PostgresSQL
  // config.sequelize = {
  //   dialect: 'postgres',//db类型
  //   database: 'postgres',//数据库名
  //   host: '127.0.0.1',//主机
  //   port: '5432',//端口
  //   username: 'postgres',
  //   password: '123456',
  // };
  config.knex = {
    client: {
      dialect: 'postgresql',
      connection: {
        host: 'localhost',
        port: '5432',
        user: 'postgres',
        password: 123456,
        database: 'chat',
      },
      pool: { min: 0, max: 5 },
      acquireConnectionTimeout: 30000,
    },
    app: true,
    agent: false,
  }
  config.io = {
    namespace: {
      '/': {
        // connectionMiddleware是在client保持连接的时候调用的中间件
        connectionMiddleware: ['connection'],
        // packetMiddleware是在server发送包给client之后调用的中间件
        packetMiddleware: [],
      }
    },
  };
  // add your middleware config here
  // config.middleware = [];
  // config.jwt = {
  //   secret: '123456',
  // };
  // 跨域配置
  // config.cors = {
  //   origin: '*',
  //   allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  // };
  // 安全配置 （https://eggjs.org/zh-cn/core/security.html）
  config.security = {
    csrf: {
      enable: false,
      ignoreJSON: true,
    },
    domainWhiteList: ['*'],
  };
  const userConfig = {
  };

  return {
    ...config,
    ...userConfig,
  };
};
